# 编写一个程序，注册 5 个账号，账号存于字典中，键为姓名，值为密码，
# 如果名字已存在，提示用户已存在，
# 请重新输入，密码不少于 6 位且只能是数字和字母，注册完后跳出循环，打印出注册的账号

# dict = {}
# while True:
#     name = input("账号")
#     pwd = input("密码")
#     if name in dict:
#         print("用户已存在")
#     else:
#         if len(pwd) >= 6 and pwd.isalnum():
#             dict[name] = pwd
#             print("注册成功")
#         else:
#             print("不合规矩")
#     if len(dict) == 5 :
#         print("注册的账号：",dict)
#         break

#选择排序
# data = [1,56,6,5,4,89,2]
# for i in range(len(data)):
#     min_index = i
#     for j in range(i+1,len(data)):
#         if data[j] < data[min_index]:
#             min_index = j
#             data[min_index],data[i] = data[i],data[min_index]
# print(data)

# def show(n):
#     print("show run ...{n}")
# a = show
# a(10)

# def out_func():
#     out_n = 100
#     def inner_func():
#         out_n = 200
#         print(out_n)
#     return inner_func()
# f1 = out_func()
# f1()
# import  time
#
# def count_time():
#     def inner_func(func):
#         start_time = time.time()
#         func()
#         end_time = time.time()
#         print(f"耗时为：{end_time-start_time}秒")
#     return inner_func
#
# @count_time
# def timecaculate():
#     for i in range(5):
#         time.sleep(1)
# timecaculate()

# def out_func_deco(func):
#     # 内部函数可变参数，用来接受被装饰函数使用的参数
#     def inner_func_deco(*args,**kwargs):
#         # 装饰器的功能代码
#         print("执行函数前的装饰器功能代码")
#         result = func(*args,**kwargs)
#         # 装饰器的功能代码
#         print("执行函数后的装饰器功能代码")
#         # 返回被装饰函数的执行结果
#         return result
#     # fanh
#     return inner_func_deco
# def show_num(n):
#     for i in range(n):
#         print(f"第{i+1}循环")
#     return "执行结束"
# a = show_num(5)
# print(a)

# 定义装饰器函数
# def count_calls(func):
#     count = 0  # 初始化计数器变量
#
#     def wrapper(*args, **kwargs):
#         nonlocal count
#         count += 1
#         print(f"函数 '{func.__name__}' 已被调用 {count} 次。")
#         return func(*args, **kwargs)  # 调用原始函数
#
#     return wrapper
#
#
# # 使用装饰器来计数函数调用
# @count_calls
# def greet(name):
#     return f"Hello, {name}!"
#
#
# # 调用被装饰的函数
# print(greet("Alice"))
# print(greet("Bob"))
# print(greet("Charlie"))

# from math import sqrt as n
# print(n(25))

# import datetime

# print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
#
# import my_module
# print(dir(my_module))
# print(my_module.__doc__)

# from my_module import add,nowdateformat
# print(add(10,15))
# print(nowdateformat())


# class Person():
#     #初始化方法
#     def __init__(self,name,gender,age,height):
#         print("在实例化类的时候，自动调用init方法")
#         self.name = name
#         self.gender = gender
#         self.age = age
#         self.height = height
#     def run(self,m):
#         print(f"{self.name} 每分钟 跑{m}米")
#     def hobby(self,m):
#         print(f"{self.name} 爱好是 {m}")
# #类的实例化 类的实例 ==类的对象
# p = Person("小明","男","18","180")
# print(p.name)
# print(p.height)
#
# p.run(300)
# p.hobby("打篮球")
#
# class PersonWeight(Person):
#
#     country = "中国"
#
#     def __init__(self,name,gender,age,height,weight):
#         super().__init__(name,gender,age,height)
#         self.weight = weight
#     def weightnotify(self):
#         print(f"{self.name} 体重是{self.weight}")
#     def belongtocountry(self):
#         print(f"{self.name} 的国家是{self.country}")

# pw = Person("小红","女","18",170,75)
# pw.weightnotify()
# pw.run()
# pw.hobby("跳舞")
# print(PersonWeight.country)
# print()

# class Father():
#     def cure(self):
#         print("中医")
# class Son(Father):
#     def cure(self):
#         print("西医")
# class Patient():
#     def needDoctor(self,doctor):
#         doctor.cure()
# if __name__ == '__main__':
#     oldDoctor = Father()
#     littleDoctor = Son()
#     patient = Patient()
#
#     patient.needDoctor(oldDoctor)
#     patient.needDoctor(littleDoctor)
# class Product:
#     def __init__(self,name,price):
#         self.name = name
#         self.price = price
#     def add_product(self):
#         print(f"Produce:{self.name},Pice{self.price}")
#     def add_car(self,cart):
#         print(f"向购物车中添加商品{self.price}成功")
#
# class ShoppingCart():
#
#     def __init__(self,productlist):
#         self.prodctlist = []
#     def addProduct(self,name):
#         self.prodctlist.append(name)
#
#     def displayallproduct(self):
#         print(self.prodctlist)
#
# if __name__ == '__main__':
#     product1 = Product("Apple", 5.0)
#     product2 = Product("Banana", 3.0)
#     product3 = Product("Orange", 4.0)
#  # 创建购物车对象
#     cart = ShoppingCart()
#
#     # 添加商品到购物车
#     product1.add_car(cart)
#     product2.add_car(cart)
#     product3.add_car(cart)
#
#     # 显示购物车中的商品信息
#     print("Shopping Cart:")
#     cart.show_products()

# class exe:
#     def __init__(self,name,weight):
#         self.name = name
#         self.weight = weight
#     def eat(self):
#         print(f"{self.name}吃完饭前体重为{self.weight}公斤")
#         self.weight += 1
#         print(f"{self.name}吃完饭后体重为{self.weight}公斤")
#     def running(self):
#         print(f"{self.name}跑步前体重为{self.weight}公斤")
#         self.weight -= 0.5
#         print(f"{self.name}跑步后体重为{self.weight}公斤")
# xiaoming =exe("小明",80)
# xiaomei =exe("小美",60)
# xiaoming.running()
# xiaoming.eat()
#
# xiaomei.running()
# xiaomei.eat()

# class House():
#
#     def __init__(self,housetype,area,furniture=[]):
#         self.housetype = housetype
#         self.area = area
#         self.furuniture = furniture
#     def add(self,furniturename):
#         if furniturename == "床" :
#             self.furuniture[furniturename] = 4
#         elif furniturename == "衣柜":
            
